<?php
namespace ManiaLivePlugins\MLEPP\ServerInfo\Gui\Controls;

use ManiaLib\Gui\Elements\Button;
use ManiaLive\Gui\Windowing\Controls\Pager;
use ManiaLive\PluginHandler\PluginHandler;
use ManiaLivePlugins\MLEPP\ServerInfo\ServerInfo;
use ManiaLive\Gui\Handler\GuiHandler;
use ManiaLive\DedicatedApi\Xmlrpc\Client_Gbx;
use ManiaLive\Database\Connection;
use ManiaLive\Data\Storage;
use ManiaLive\Threading\Commands\Command;
use ManiaLive\Threading\ThreadPool;
use ManiaLib\Gui\Elements\Label;
use ManiaLib\Gui\Elements\Quad;

class GeneralTab extends \ManiaLive\Gui\Windowing\Controls\Tab
{
   protected $pgGeneral;

	function initializeComponents()
    {
		
       
        $this->pgGeneral = new Pager();
        $this->pgGeneral->setPosition(0,5);
        $this->pgGeneral->setStretchContentX(true);
        $this->addComponent($this->pgGeneral);
		
		$this->btnFav = new Button();
        $this->pgGeneral->addComponent($this->btnFav);	

		$this->btnHomepage = new Button();
        $this->pgGeneral->addComponent($this->btnHomepage);
		$this->btnHomepage->setVisibility(true);

		$this->btnJoin = new Button();
        $this->pgGeneral->addComponent($this->btnJoin);
		$this->btnJoin->setVisibility(true);

		$this->btnContact = new Button();
        $this->pgGeneral->addComponent($this->btnContact);
		$this->btnContact->setVisibility(true);
    }
	
	
	function generalList()
    {
		$storage = Storage::getInstance();
    	
		    $this->pgGeneral->clearItems();
   
            $item = new ListItem();
			$item->label->setText('$oThis is an ' . ServerInfo::$TeamName . ' team server.' );
            $this->pgGeneral->addItem($item);
       		
			$item = new ListItem();
			$item->label->setText('$oServer Admin:$o ' . ServerInfo::$AdminName);
			$this->pgGeneral->addItem($item);
			
		// buttons
			$this->btnFav->setText('$z$000Add ' . $storage->server->name . '  $z$000to your favourites');
			$this->btnFav->setUrl('tmtp://#addfavourite='.$storage->serverLogin);
			$this->btnFav->setPosition(14, 12);
			$this->btnFav->setStyle(Button::CardButtonMediumWide);
			
			if( !empty(ServerInfo::$TeamSite) ) {
			$this->btnHomepage->setUrl(ServerInfo::$TeamSite);
			$color = '$000';
			}
			else {
			$color = '$aaa';
			} 
			$this->btnHomepage->setText('$z'.$color.'Visit the ' . ServerInfo::$TeamName . ' $z'.$color.'website');
			$this->btnHomepage->setPosition(14, 19);
			$this->btnHomepage->setStyle(Button::CardButtonMediumWide);
				
			if( !empty(ServerInfo::$TeamJoin) ) {
			$this->btnJoin->setUrl(ServerInfo::$TeamJoin);
			$color = '$000';
			}
			else {
			$color = '$aaa';
			}
			$this->btnJoin->setText('$z'.$color.'Learn how to join ' . ServerInfo::$TeamName);
			$this->btnJoin->setPosition(14, 26);
			$this->btnJoin->setStyle(Button::CardButtonMediumWide);
	

			if( !empty(ServerInfo::$AdminContact) ) {
			$this->btnContact->setUrl(ServerInfo::$AdminContact);
			$color = '$000';
			}
			else {
			$color = '$aaa';
			}
			$this->btnContact->setText('$z'.$color.'Send ' . ServerInfo::$AdminName . '  $z'.$color.'a message');
			$this->btnContact->setPosition(14, 33);
			$this->btnContact->setStyle(Button::CardButtonMediumWide);	        
		
    } 
	
    function onResize()
    {
        $this->pgGeneral->setSize($this->sizeX, $this->sizeY-5);
    }
}

?>